/**
 * 移动端优化样式
 * @description 专门针对移动端设备的样式优化
 */

/* 移动端导航样式 */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--color-bg-primary);
  border-top: 1px solid var(--color-border-secondary);
  padding: var(--spacing-xs) 0;
  z-index: var(--z-index-fixed);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

.mobile-nav-list {
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mobile-nav-item {
  flex: 1;
  text-align: center;
}

.mobile-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--spacing-xs);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: var(--transition-fast);
  border-radius: var(--border-radius-md);
  margin: 0 var(--spacing-xs);
  min-height: 48px;
  justify-content: center;
}

.mobile-nav-link:hover,
.mobile-nav-link.active {
  color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.mobile-nav-icon {
  font-size: 20px;
  margin-bottom: 2px;
}

.mobile-nav-text {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

/* 移动端头部样式 */
.mobile-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--color-bg-primary);
  border-bottom: 1px solid var(--color-border-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing-md);
  z-index: var(--z-index-fixed);
  box-shadow: var(--shadow-sm);
}

.mobile-header-left,
.mobile-header-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.mobile-header-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0;
}

.mobile-header-back {
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  color: var(--color-text-primary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
}

.mobile-header-back:hover {
  background-color: var(--color-bg-secondary);
}

/* 移动端内容区域 */
.mobile-content {
  padding-top: var(--header-height);
  padding-bottom: calc(var(--footer-height) + var(--spacing-md));
  min-height: 100vh;
  background-color: var(--color-bg-secondary);
}

.mobile-page {
  padding: var(--spacing-md);
}

/* 触摸优化按钮 */
.touch-button {
  min-height: 44px;
  min-width: 44px;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--border-radius-md);
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  touch-action: manipulation;
  user-select: none;
}

.touch-button:hover {
  background-color: var(--color-bg-secondary);
  border-color: var(--color-primary);
}

.touch-button:active {
  transform: scale(0.98);
  background-color: var(--color-bg-tertiary);
}

.touch-button.primary {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
}

.touch-button.primary:hover {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.touch-button.primary:active {
  background-color: var(--color-primary-active);
  border-color: var(--color-primary-active);
}

.touch-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* 移动端表单优化 */
.mobile-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.mobile-form-item {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.mobile-form-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

.mobile-form-input {
  min-height: 44px;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--border-radius-md);
  font-size: 16px; /* 防止 iOS 缩放 */
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  transition: var(--transition-fast);
}

.mobile-form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

.mobile-form-textarea {
  min-height: 88px;
  resize: vertical;
}

.mobile-form-select {
  min-height: 44px;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--border-radius-md);
  font-size: 16px;
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  cursor: pointer;
}

/* 课表滑动查看功能 */
.schedule-swiper {
  position: relative;
  overflow: hidden;
  touch-action: pan-x;
}

.schedule-swiper-container {
  display: flex;
  transition: transform 0.3s ease-out;
}

.schedule-swiper-slide {
  flex: 0 0 100%;
  width: 100%;
}

.schedule-swiper-indicators {
  display: flex;
  justify-content: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-md);
}

.schedule-swiper-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-border-primary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.schedule-swiper-dot.active {
  background-color: var(--color-primary);
  transform: scale(1.2);
}

.schedule-swiper-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background-color: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--color-border-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
  z-index: 10;
}

.schedule-swiper-nav:hover {
  background-color: var(--color-bg-primary);
  box-shadow: var(--shadow-md);
}

.schedule-swiper-prev {
  left: var(--spacing-sm);
}

.schedule-swiper-next {
  right: var(--spacing-sm);
}

/* 移动端课表卡片 */
.mobile-schedule-card {
  background-color: var(--color-bg-primary);
  border: 1px solid var(--color-border-secondary);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  position: relative;
  overflow: hidden;
}

.mobile-schedule-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--color-primary);
}

.mobile-schedule-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--spacing-sm);
}

.mobile-schedule-title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0;
  flex: 1;
}

.mobile-schedule-time {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  white-space: nowrap;
  margin-left: var(--spacing-sm);
}

.mobile-schedule-info {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.mobile-schedule-detail {
  display: flex;
  align-items: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.mobile-schedule-icon {
  margin-right: var(--spacing-xs);
  color: var(--color-text-tertiary);
  width: 16px;
  text-align: center;
}

/* 移动端模态框优化 */
.mobile-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-index-modal);
  display: flex;
  flex-direction: column;
}

.mobile-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
}

.mobile-modal-content {
  position: relative;
  background-color: var(--color-bg-primary);
  border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
  margin-top: auto;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mobile-modal-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--color-border-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.mobile-modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0;
}

.mobile-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--color-text-secondary);
  font-size: 18px;
  cursor: pointer;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.mobile-modal-close:hover {
  background-color: var(--color-bg-secondary);
  color: var(--color-text-primary);
}

.mobile-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md);
}

.mobile-modal-footer {
  padding: var(--spacing-md);
  border-top: 1px solid var(--color-border-secondary);
  display: flex;
  gap: var(--spacing-sm);
  flex-shrink: 0;
}

.mobile-modal-footer .touch-button {
  flex: 1;
}

/* 移动端列表优化 */
.mobile-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.mobile-list-item {
  background-color: var(--color-bg-primary);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-md);
  border: 1px solid var(--color-border-secondary);
  transition: var(--transition-fast);
}

.mobile-list-item:active {
  background-color: var(--color-bg-secondary);
  transform: scale(0.98);
}

.mobile-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.mobile-list-title {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  font-size: var(--font-size-md);
}

.mobile-list-meta {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.mobile-list-content {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.mobile-list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mobile-list-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.mobile-list-value {
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  font-weight: var(--font-weight-medium);
}

/* 移动端搜索优化 */
.mobile-search {
  position: sticky;
  top: var(--header-height);
  background-color: var(--color-bg-primary);
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--color-border-secondary);
  z-index: 20;
}

.mobile-search-input {
  width: 100%;
  min-height: 44px;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--border-radius-lg);
  font-size: 16px;
  background-color: var(--color-bg-secondary);
  color: var(--color-text-primary);
}

.mobile-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  background-color: var(--color-bg-primary);
}

/* 安全区域适配 */
.safe-area-top {
  padding-top: env(safe-area-inset-top);
}

.safe-area-bottom {
  padding-bottom: env(safe-area-inset-bottom);
}

.safe-area-left {
  padding-left: env(safe-area-inset-left);
}

.safe-area-right {
  padding-right: env(safe-area-inset-right);
}

/* 横屏适配 */
@media (orientation: landscape) and (max-height: 500px) {
  .mobile-header {
    height: 48px;
  }
  
  .mobile-content {
    padding-top: 48px;
  }
  
  .mobile-nav {
    display: none;
  }
  
  .mobile-content {
    padding-bottom: var(--spacing-md);
  }
}

/* 超小屏幕适配 */
@media (max-width: 360px) {
  .mobile-nav-text {
    display: none;
  }
  
  .mobile-nav-link {
    min-height: 40px;
  }
  
  .mobile-header {
    padding: 0 var(--spacing-sm);
  }
  
  .mobile-page {
    padding: var(--spacing-sm);
  }
}

/* 大屏手机适配 */
@media (min-width: 414px) and (max-width: 768px) {
  .mobile-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
  }
  
  .mobile-form-full {
    grid-column: 1 / -1;
  }
}

/* 减少动画模式 */
@media (prefers-reduced-motion: reduce) {
  .schedule-swiper-container {
    transition: none;
  }
  
  .touch-button:active {
    transform: none;
  }
  
  .mobile-list-item:active {
    transform: none;
  }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
  .touch-button {
    border-width: 2px;
    font-weight: var(--font-weight-semibold);
  }
  
  .mobile-form-input,
  .mobile-form-select {
    border-width: 2px;
  }
}